Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presets #173

Merged
merged 23 commits into from
Oct 9, 2024
Merged

Presets #173

merged 23 commits into from
Oct 9, 2024

Conversation

max-mazer
Copy link
Contributor

@max-mazer max-mazer commented Oct 4, 2024

Introduced the ability to save, load, delete, and organize presets that remember which views were on screen, in what order, and their sizes.

image

Levi-Lesches
Levi-Lesches previously approved these changes Oct 9, 2024
Copy link
Member

@Levi-Lesches Levi-Lesches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Max! Here's what I changed/fixed:

  • moved some classes to their own files
  • fixed a problem when loading the preset JSON: In a few cases, you were trying to load a List<SomeDartType>, but JSON only works with strings, numbers, bools, or lists/maps of those. So in cases where you want, say a List<ViewPreset> from JSON, I manually looped over the list of smaller JSONs and passed each one to ViewPreset.fromJson, and built a list that way. With a list comprehension, if you're familiar.
  • In some cases, you were using FilesService.writeSettings directly. That does work, but it only changes your files on disk -- it does not alert Flutter that something has changed. So I switched all those calls to SettingsModel.update instead, and told the sidebar to listen for those changes.
  • There was a little clippy warning in the corner if the presets, or any other setting, fail to load. That's because in release mode we simply override any corrupt settings with the defaults. I changed it so that in debug mode it throws a full-on error and does not wipe your settings.
  • Instead of loading a preset via a dialog, I added all the presets themselves to the ExpansionTile. Clicking on one will load it automatically, and clicking the little delete icon will delete it. The delete dialog still appears, but it no longer asks you to choose a preset since you had to click the delete icon next to the preset.
  • The old version of flutter_resizable_container was giving some issues with precision (eg, ratios adding to 0.9999999 and not 1.0). Upgrading from 0.4.2 to 3.0.0 helped, and after a little reconfiguring, introduced no further bugs

The errors were pretty subtle, so don't worry about not catching them in the code, but maybe a bit more testing could have caught them (eg, restart to find none of the presets are loaded). Anyway, it's ready to merge now, just figured I'd let you press the green button.

Levi-Lesches
Levi-Lesches previously approved these changes Oct 9, 2024
Copy link
Member

@Levi-Lesches Levi-Lesches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving after upgrading the resizable container package

Copy link
Member

@Levi-Lesches Levi-Lesches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an option to re-order your presets so users can organize them as they wish

@max-mazer max-mazer merged commit 362a2da into main Oct 9, 2024
2 checks passed
@max-mazer max-mazer deleted the presets branch October 9, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants